package chapter03;

import java.util.Stack;

public class Q21 {


    public boolean isValid(String s) {
        if (s == null || s.length() == 0) {
            return true;
        }
        Stack<Character> stack = new Stack<Character>();
        char[] chars = s.toCharArray();
        char prev = 0;
        for (char cha: chars) {
            if (cha == '{') {
                stack.push('}');
            } else if (cha == '[') {
                stack.push(']');
            } else if (cha == '(') {
                stack.push(')');
            } else if (cha == '/') {
                if (prev != '*') {
                    stack.push(cha);
                }else {
                    //闭括号 */
                    if (stack.isEmpty() || (stack.pop() != '/')) {
                        return false;
                    }
                }
            }else if (cha == '*') {
                if (prev == '/') {
                    stack.push(cha);
                }else {



                }
            }

            else if (stack.isEmpty() || stack.pop() != cha) {
                return false;
            }
        }
        return stack.isEmpty();
    }
}
